//clear all field
var clear = document.getElementById('clear');
clear.addEventListener('click', clearfield,true);

function clearfield(){
    document.getElementById('username').value   = '';
    document.getElementById('tel').value        = ''; 
    document.getElementById('mail').value      = '';
    document.getElementById('number1').value    = '';
    document.getElementById('number2').value    = '';	
    document.getElementById('number3').value    = '';
    document.getElementById('number4').value    = '';
}


//confrim to sumit
var conf = document.getElementById('consub');
conf.addEventListener('click', confrimSumbit,true);

function confrimSumbit(){
 if(confirm("Are you sure to sumbit?")){
 alert("A new password is sent to your email address\nplease reset your password as soon as possible.");
 window.location = "login2.html";
 }
}

//check if the email is valid
 var  email = document.getElementById('mail');
 email.addEventListener('change', checkmail, true);
 
function checkmail() 
{ 
var emailAddress = document.getElementById('mail').value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(emailAddress))
testresults=true
else{
alert("You must enter a valid email address!")
testresults=false
}
return (testresults)
} 

